let box = document.querySelector(".box");
let imgButtons = document.getElementsByTagName("input")
let boxImageClass = box.classList[1];
for (let i = 0; i < imgButtons.length; i++) {
  imgButtons[i].onclick = function (e) {
    let targetClass = e.target.className;
    if (boxImageClass != targetClass) {
      box.classList.replace(boxImageClass, targetClass);
      boxImageClass = targetClass;
    }
  }
}

